#from django.http import HttpResponse
from django.shortcuts import render_to_response
from django.template import RequestContext
from comunidadpaz.settings import MEDIA_URL
from comunidadpaz.portada.models import *
from comunidadpaz.photologue_local.models import Gallery
from django.views.generic.simple import direct_to_template

general_options = {'MEDIA_URL': MEDIA_URL}

def home(request):
    render = {}
    render.update(general_options)
    try:
        galeria = Gallery.objects.get(title="pagina_principal")
        galeria_portada = galeria.sample(public=True)
        galeria_portada = galeria.public()  
    except Gallery.DoesNotExist:
        galeria_portada = {}

    render['galeria'] = galeria_portada
    return render_to_response('homepage.html',
                                render, 
                                context_instance = RequestContext(request))
